function varargout=state_space_f(n,k,t,Q,H,Tea,Theta,q,p,Z)

% State Space system as in Harvey (1989)
% measurement equation: y(t) = d + Z alpha(t) + epsilon(t)
% transition equation: alpha(t+1) = c + T alpha(t) + R eta(t)
% with eta(t)~N(0,Q)
Q = diag(Q(:,t));
d = 0;
if t==1
    Zcom = [Z(:,:,t),zeros(n,k*(q-1))];
else
    Zcom = [Z(:,:,t),-Theta*Z(:,:,t-1),zeros(n,k*(q-1-p))];
end

[Tcom,Qcom]=VARcompanion(Tea,Q,0);

varargout(1) = {H};
varargout(2) = {Tea};
varargout(3) = {Tcom};
varargout(4) = {Q};
varargout(5) = {Qcom};
varargout(6) = {Zcom};
varargout(7) = {d};



